﻿// =================================================================== 
// 项目说明
//====================================================================
// 
// 文件： SYS_BULLETIN_LIST.cs
// 项目名称：


// 创建时间：2015-3-10
// 负责人：
// ===================================================================
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using CommonLib.Model;
using CommonLib.IDAL;


//注意：该文件自动生成，一般请不要手工修改。




namespace MSSQLDAL
{
    /// <summary>
    /// 数据层实例化接口类 .
    /// </summary>
    public partial class SYS_BULLETIN_LISTDAL : ISYS_BULLETIN_LISTDAL
    {
		
		 #region 变量声明（For update 和 Insert 时）
		// 声明静态变量 
		private const string PARA_BULLETIN_ID =  "@BULLETIN_ID";
		private const string PARA_CREATE_TIME =  "@CREATE_TIME";
		private const string PARA_CREATOR_ID =  "@CREATOR_ID";
		private const string PARA_CREATOR =  "@CREATOR";
		private const string PARA_DEPT_ID =  "@DEPT_ID";
		private const string PARA_DEPT_NAME =  "@DEPT_NAME";
		private const string PARA_TITLE =  "@TITLE";
		private const string PARA_CONTENT =  "@CONTENT";
		private const string PARA_PUB_TIME =  "@PUB_TIME";
		private const string PARA_INVALIDE_TIME =  "@INVALIDE_TIME";
		private const string PARA_STATE =  "@STATE";
		private const string PARA_ATTACH_FILES =  "@ATTACH_FILES";
		private const string PARA_WORK_ID =  "@WORK_ID";
		private const string PARA_REMARK =  "@REMARK";
		private const string PARA_ISRECOMMEND =  "@ISRECOMMEND";

		private const string SQL_UPDATE = "UPDATE SYS_BULLETIN_LIST SET  BULLETIN_ID= @BULLETIN_ID, CREATE_TIME= @CREATE_TIME, CREATOR_ID= @CREATOR_ID, CREATOR= @CREATOR, DEPT_ID= @DEPT_ID, DEPT_NAME= @DEPT_NAME, TITLE= @TITLE, CONTENT= @CONTENT, PUB_TIME= @PUB_TIME, INVALIDE_TIME= @INVALIDE_TIME, STATE= @STATE, ATTACH_FILES= @ATTACH_FILES, WORK_ID= @WORK_ID, REMARK= @REMARK, ISRECOMMEND= @ISRECOMMEND  WHERE BULLETIN_ID = @BULLETIN_ID ";
		private const string SQL_INSERT = "INSERT INTO SYS_BULLETIN_LIST(BULLETIN_ID, CREATE_TIME, CREATOR_ID, CREATOR, DEPT_ID, DEPT_NAME, TITLE, CONTENT, PUB_TIME, INVALIDE_TIME, STATE, ATTACH_FILES, WORK_ID, REMARK, ISRECOMMEND ) values ( @BULLETIN_ID, @CREATE_TIME, @CREATOR_ID, @CREATOR, @DEPT_ID, @DEPT_NAME, @TITLE, @CONTENT, @PUB_TIME, @INVALIDE_TIME, @STATE, @ATTACH_FILES, @WORK_ID, @REMARK, @ISRECOMMEND ) ";
		#endregion
		
		// 查询数据的sql串




		private string TableString;
		
		#region 构造函数




		/// <summary>
		/// ??????
		/// </summary>
		public SYS_BULLETIN_LISTDAL()
		{
			if (QueryDataString == "")
                TableString = "SYS_BULLETIN_LIST SQL_A";
            else
                TableString = "(" + QueryDataString + ") SQL_A";
		}
		#endregion

        //-----------实例化接口函数-----------
		
		//------------增删改函数------------------- 
		
		#region Add 向数据库中插入一条新记录。




		/// <summary>
		/// 向数据库SYS_BULLETIN_LIST中插入一条新记录。




		/// </summary>
		/// <param name="_SYS_BULLETIN_LISTModel">SYS_BULLETIN_LIST??</param>
		/// <returns>影响的行数</returns>
		public int Add(CommonLib.Model.SYS_BULLETIN_LIST _SYS_BULLETIN_LISTModel)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter(PARA_BULLETIN_ID, SqlDbType.Int), 
				new SqlParameter(PARA_CREATE_TIME, SqlDbType.DateTime), 
				new SqlParameter(PARA_CREATOR_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_CREATOR, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEPT_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEPT_NAME, SqlDbType.VarChar), 
				new SqlParameter(PARA_TITLE, SqlDbType.VarChar), 
				new SqlParameter(PARA_CONTENT, SqlDbType.VarChar), 
				new SqlParameter(PARA_PUB_TIME, SqlDbType.DateTime), 
				new SqlParameter(PARA_INVALIDE_TIME, SqlDbType.DateTime), 
				new SqlParameter(PARA_STATE, SqlDbType.Int), 
				new SqlParameter(PARA_ATTACH_FILES, SqlDbType.VarChar), 
				new SqlParameter(PARA_WORK_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_REMARK, SqlDbType.VarChar), 
				new SqlParameter(PARA_ISRECOMMEND, SqlDbType.Bit)
			};			
			
			 _param[0].Value =  _SYS_BULLETIN_LISTModel.BULLETIN_ID;
			 if (_SYS_BULLETIN_LISTModel.CREATE_TIME==String.Empty) _param[1].Value = DBNull.Value; else _param[1].Value =  _SYS_BULLETIN_LISTModel.CREATE_TIME;
			 _param[2].Value =  _SYS_BULLETIN_LISTModel.CREATOR_ID;
			 _param[3].Value =  _SYS_BULLETIN_LISTModel.CREATOR;
			 _param[4].Value =  _SYS_BULLETIN_LISTModel.DEPT_ID;
			 _param[5].Value =  _SYS_BULLETIN_LISTModel.DEPT_NAME;
			 _param[6].Value =  _SYS_BULLETIN_LISTModel.TITLE;
			 _param[7].Value =  _SYS_BULLETIN_LISTModel.CONTENT;
			 if (_SYS_BULLETIN_LISTModel.PUB_TIME==String.Empty) _param[8].Value = DBNull.Value; else _param[8].Value =  _SYS_BULLETIN_LISTModel.PUB_TIME;
			 if (_SYS_BULLETIN_LISTModel.INVALIDE_TIME==String.Empty) _param[9].Value = DBNull.Value; else _param[9].Value =  _SYS_BULLETIN_LISTModel.INVALIDE_TIME;
			 _param[10].Value =  _SYS_BULLETIN_LISTModel.STATE;
			 _param[11].Value =  _SYS_BULLETIN_LISTModel.ATTACH_FILES;
			 _param[12].Value =  _SYS_BULLETIN_LISTModel.WORK_ID;
			 _param[13].Value =  _SYS_BULLETIN_LISTModel.REMARK;
			 _param[14].Value =  _SYS_BULLETIN_LISTModel.ISRECOMMEND;

			
			//  返回
			return (int)SqlHelper.ExecuteNonQuery(Conn.SqlConnStr, CommandType.Text, SQL_INSERT, _param);


		}
		#endregion
		
		#region Add 向数据库中插入一条新记录。带事务
		/// <summary>
		/// 向数据库SYS_BULLETIN_LIST中插入一条新记录。带事务
		/// </summary>
		/// <param name="sp">事务对象</param>
		/// <param name="_SYS_BULLETIN_LISTModel">SYS_BULLETIN_LIST实体</param>
		/// <returns>影响的行数</returns>
		public int Add(DBTransaction dbTrans,CommonLib.Model.SYS_BULLETIN_LIST _SYS_BULLETIN_LISTModel)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter(PARA_BULLETIN_ID, SqlDbType.Int), 
				new SqlParameter(PARA_CREATE_TIME, SqlDbType.DateTime), 
				new SqlParameter(PARA_CREATOR_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_CREATOR, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEPT_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEPT_NAME, SqlDbType.VarChar), 
				new SqlParameter(PARA_TITLE, SqlDbType.VarChar), 
				new SqlParameter(PARA_CONTENT, SqlDbType.VarChar), 
				new SqlParameter(PARA_PUB_TIME, SqlDbType.DateTime), 
				new SqlParameter(PARA_INVALIDE_TIME, SqlDbType.DateTime), 
				new SqlParameter(PARA_STATE, SqlDbType.Int), 
				new SqlParameter(PARA_ATTACH_FILES, SqlDbType.VarChar), 
				new SqlParameter(PARA_WORK_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_REMARK, SqlDbType.VarChar), 
				new SqlParameter(PARA_ISRECOMMEND, SqlDbType.Bit)
			};	
			
			 _param[0].Value =  _SYS_BULLETIN_LISTModel.BULLETIN_ID;
			 if (_SYS_BULLETIN_LISTModel.CREATE_TIME==String.Empty) _param[1].Value = DBNull.Value; else _param[1].Value =  _SYS_BULLETIN_LISTModel.CREATE_TIME;
			 _param[2].Value =  _SYS_BULLETIN_LISTModel.CREATOR_ID;
			 _param[3].Value =  _SYS_BULLETIN_LISTModel.CREATOR;
			 _param[4].Value =  _SYS_BULLETIN_LISTModel.DEPT_ID;
			 _param[5].Value =  _SYS_BULLETIN_LISTModel.DEPT_NAME;
			 _param[6].Value =  _SYS_BULLETIN_LISTModel.TITLE;
			 _param[7].Value =  _SYS_BULLETIN_LISTModel.CONTENT;
			 if (_SYS_BULLETIN_LISTModel.PUB_TIME==String.Empty) _param[8].Value = DBNull.Value; else _param[8].Value =  _SYS_BULLETIN_LISTModel.PUB_TIME;
			 if (_SYS_BULLETIN_LISTModel.INVALIDE_TIME==String.Empty) _param[9].Value = DBNull.Value; else _param[9].Value =  _SYS_BULLETIN_LISTModel.INVALIDE_TIME;
			 _param[10].Value =  _SYS_BULLETIN_LISTModel.STATE;
			 _param[11].Value =  _SYS_BULLETIN_LISTModel.ATTACH_FILES;
			 _param[12].Value =  _SYS_BULLETIN_LISTModel.WORK_ID;
			 _param[13].Value =  _SYS_BULLETIN_LISTModel.REMARK;
			 _param[14].Value =  _SYS_BULLETIN_LISTModel.ISRECOMMEND;

			
			//  返回
			return (int)SqlHelper.ExecuteNonQuery(dbTrans.sql_trans, CommandType.Text, SQL_INSERT, _param);
		}
		#endregion
		
		#region	Update 向数据表更新一条记录。	
		/// <summary>
		/// 向数据表SYS_BULLETIN_LIST更新一条记录。




		/// </summary>
		/// <param name="_SYS_BULLETIN_LISTModel">_SYS_BULLETIN_LISTModel</param>
		/// <returns>影响的行数</returns>
		public int Update(CommonLib.Model.SYS_BULLETIN_LIST _SYS_BULLETIN_LISTModel)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter(PARA_BULLETIN_ID, SqlDbType.Int), 
				new SqlParameter(PARA_CREATE_TIME, SqlDbType.DateTime), 
				new SqlParameter(PARA_CREATOR_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_CREATOR, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEPT_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEPT_NAME, SqlDbType.VarChar), 
				new SqlParameter(PARA_TITLE, SqlDbType.VarChar), 
				new SqlParameter(PARA_CONTENT, SqlDbType.VarChar), 
				new SqlParameter(PARA_PUB_TIME, SqlDbType.DateTime), 
				new SqlParameter(PARA_INVALIDE_TIME, SqlDbType.DateTime), 
				new SqlParameter(PARA_STATE, SqlDbType.Int), 
				new SqlParameter(PARA_ATTACH_FILES, SqlDbType.VarChar), 
				new SqlParameter(PARA_WORK_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_REMARK, SqlDbType.VarChar), 
				new SqlParameter(PARA_ISRECOMMEND, SqlDbType.Bit)
			};	
			
			 _param[0].Value =  _SYS_BULLETIN_LISTModel.BULLETIN_ID;
			 if (_SYS_BULLETIN_LISTModel.CREATE_TIME==String.Empty) _param[1].Value = DBNull.Value; else _param[1].Value =  _SYS_BULLETIN_LISTModel.CREATE_TIME;
			 _param[2].Value =  _SYS_BULLETIN_LISTModel.CREATOR_ID;
			 _param[3].Value =  _SYS_BULLETIN_LISTModel.CREATOR;
			 _param[4].Value =  _SYS_BULLETIN_LISTModel.DEPT_ID;
			 _param[5].Value =  _SYS_BULLETIN_LISTModel.DEPT_NAME;
			 _param[6].Value =  _SYS_BULLETIN_LISTModel.TITLE;
			 _param[7].Value =  _SYS_BULLETIN_LISTModel.CONTENT;
			 if (_SYS_BULLETIN_LISTModel.PUB_TIME==String.Empty) _param[8].Value = DBNull.Value; else _param[8].Value =  _SYS_BULLETIN_LISTModel.PUB_TIME;
			 if (_SYS_BULLETIN_LISTModel.INVALIDE_TIME==String.Empty) _param[9].Value = DBNull.Value; else _param[9].Value =  _SYS_BULLETIN_LISTModel.INVALIDE_TIME;
			 _param[10].Value =  _SYS_BULLETIN_LISTModel.STATE;
			 _param[11].Value =  _SYS_BULLETIN_LISTModel.ATTACH_FILES;
			 _param[12].Value =  _SYS_BULLETIN_LISTModel.WORK_ID;
			 _param[13].Value =  _SYS_BULLETIN_LISTModel.REMARK;
			 _param[14].Value =  _SYS_BULLETIN_LISTModel.ISRECOMMEND;
			
			return SqlHelper.ExecuteNonQuery(Conn.SqlConnStr, CommandType.Text, SQL_UPDATE, _param);
		}
		#endregion
		
		#region	Update 向数据表更新一条记录。带事务	
		/// <summary>
		/// 向数据表SYS_BULLETIN_LIST更新一条记录。带事务
		/// </summary>
		/// <param name="sp">事务对象</param>
		/// <param name="_SYS_BULLETIN_LISTModel">_SYS_BULLETIN_LISTModel</param>
		/// <returns>影响的行数</returns>
		public int Update(DBTransaction dbTrans,CommonLib.Model.SYS_BULLETIN_LIST _SYS_BULLETIN_LISTModel)
		{
           // 声明参数数组并赋值




		    SqlParameter[] _param=
			{
				new SqlParameter(PARA_BULLETIN_ID, SqlDbType.Int), 
				new SqlParameter(PARA_CREATE_TIME, SqlDbType.DateTime), 
				new SqlParameter(PARA_CREATOR_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_CREATOR, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEPT_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_DEPT_NAME, SqlDbType.VarChar), 
				new SqlParameter(PARA_TITLE, SqlDbType.VarChar), 
				new SqlParameter(PARA_CONTENT, SqlDbType.VarChar), 
				new SqlParameter(PARA_PUB_TIME, SqlDbType.DateTime), 
				new SqlParameter(PARA_INVALIDE_TIME, SqlDbType.DateTime), 
				new SqlParameter(PARA_STATE, SqlDbType.Int), 
				new SqlParameter(PARA_ATTACH_FILES, SqlDbType.VarChar), 
				new SqlParameter(PARA_WORK_ID, SqlDbType.VarChar), 
				new SqlParameter(PARA_REMARK, SqlDbType.VarChar), 
				new SqlParameter(PARA_ISRECOMMEND, SqlDbType.Bit)
			};		
			
			 _param[0].Value =  _SYS_BULLETIN_LISTModel.BULLETIN_ID;
			 if (_SYS_BULLETIN_LISTModel.CREATE_TIME==String.Empty) _param[1].Value = DBNull.Value; else _param[1].Value =  _SYS_BULLETIN_LISTModel.CREATE_TIME;
			 _param[2].Value =  _SYS_BULLETIN_LISTModel.CREATOR_ID;
			 _param[3].Value =  _SYS_BULLETIN_LISTModel.CREATOR;
			 _param[4].Value =  _SYS_BULLETIN_LISTModel.DEPT_ID;
			 _param[5].Value =  _SYS_BULLETIN_LISTModel.DEPT_NAME;
			 _param[6].Value =  _SYS_BULLETIN_LISTModel.TITLE;
			 _param[7].Value =  _SYS_BULLETIN_LISTModel.CONTENT;
			 if (_SYS_BULLETIN_LISTModel.PUB_TIME==String.Empty) _param[8].Value = DBNull.Value; else _param[8].Value =  _SYS_BULLETIN_LISTModel.PUB_TIME;
			 if (_SYS_BULLETIN_LISTModel.INVALIDE_TIME==String.Empty) _param[9].Value = DBNull.Value; else _param[9].Value =  _SYS_BULLETIN_LISTModel.INVALIDE_TIME;
			 _param[10].Value =  _SYS_BULLETIN_LISTModel.STATE;
			 _param[11].Value =  _SYS_BULLETIN_LISTModel.ATTACH_FILES;
			 _param[12].Value =  _SYS_BULLETIN_LISTModel.WORK_ID;
			 _param[13].Value =  _SYS_BULLETIN_LISTModel.REMARK;
			 _param[14].Value =  _SYS_BULLETIN_LISTModel.ISRECOMMEND;
			

			
			return SqlHelper.ExecuteNonQuery(dbTrans.sql_trans, CommandType.Text, SQL_UPDATE, _param);
		}
		#endregion
		
		#region	Delete 根据主键，删除数据表中的一条记录	
		/// <summary>
		/// 根据主键，删除数据表SYS_BULLETIN_LIST中的一条记录




		/// </summary>
	    /// <param name="bULLETIN_ID">bULLETIN_ID</param>
		/// <returns>影响的行数</returns>
		public int Delete(int bULLETIN_ID)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter("@bULLETIN_ID", SqlDbType.Int)
			};				
			_param[0].Value = bULLETIN_ID;
			
			string sqlStr="delete from SYS_BULLETIN_LIST where  BULLETIN_ID=@bULLETIN_ID";
			return SqlHelper.ExecuteNonQuery(Conn.SqlConnStr, CommandType.Text, sqlStr, _param);;
		}
		#endregion
		
		#region	Delete 根据主键，删除数据表中的一条记录 带事务




		/// <summary>
		/// 根据主键，删除数据表SYS_BULLETIN_LIST中的一条记录 带事务




		/// <param name="sp">事务对象</param>
	    /// <param name="BULLETIN_ID">bULLETIN_ID</param>
		/// <returns>影响的行数</returns>
		public int Delete(DBTransaction dbTrans,int bULLETIN_ID)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter("@bULLETIN_ID", SqlDbType.Int)
			};				
			_param[0].Value = bULLETIN_ID;

			string sqlStr="delete from SYS_BULLETIN_LIST where  BULLETIN_ID=@bULLETIN_ID";
			return SqlHelper.ExecuteNonQuery(dbTrans.sql_trans, CommandType.Text, sqlStr,_param);;

		}
		#endregion
		
		#region	DeleteFK 根据条件串，删除数据表中的N条记录	
		/// <summary>
		/// 根据条件串，删除数据表SYS_BULLETIN_LIST中的N条记录




		/// </summary>
	    /// <param name="sWhere">条件串</param>
		/// <returns>影响的行数</returns>
		public int DeleteFK(string sWhere)
		{
			string  sqlStr="delete from SYS_BULLETIN_LIST";
			if (sWhere.Length>0)
				sqlStr += " where "+sWhere;
			return SqlHelper.ExecuteNonQuery(Conn.SqlConnStr, CommandType.Text, sqlStr);
		}
		#endregion
		
		#region	DeleteFK 删除数据表中的一条记录,带事务	
		/// <summary>
		/// 删除数据表SYS_BULLETIN_LIST中的一条记录,带事务




		/// </summary>
		/// <param name="sp">事务对象</param>
	    /// <param name="sWhere">条件串</param>
		/// <returns>影响的行数</returns>
		public int DeleteFK(DBTransaction dbTrans,string sWhere)
		{
			string  sqlStr="delete from SYS_BULLETIN_LIST";
			if (sWhere.Length>0)
				sqlStr += " where "+sWhere;
			return SqlHelper.ExecuteNonQuery(dbTrans.sql_trans, CommandType.Text, sqlStr);
		}
		
		#endregion
		
		
		//------------获取数据及模型函数




		
		#region Exists 检测是否存在该主键
		/// <summary>
        /// 检测是否存在该主键
        /// </summary>
        /// <param name="int bULLETIN_ID" 主键列表</param>
        /// <returns>是/否</returns>
		public bool Exists(int bULLETIN_ID)
		{
			
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter("@bULLETIN_ID", SqlDbType.Int)
			};				
			_param[0].Value = bULLETIN_ID;
			
            string sqlStr="select Count(*) from SYS_BULLETIN_LIST where  BULLETIN_ID=@bULLETIN_ID and BULLETIN_ID=@bULLETIN_ID";
						
            int a=Convert.ToInt32(SqlHelper.ExecuteScalar(Conn.SqlConnStr,CommandType.Text,sqlStr,_param));
            if(a>0)
            {
                return true;
            }
            else
            {
                return false;
            }
		}

		#endregion

		#region GetModel 根据主键ID,得到数据实体
        /// <summary>
		/// 根据主键ID,得到 sys_bulletin_list 数据实体
		/// </summary>
		/// <param name="int bULLETIN_ID" 主键列表</param>
		/// <returns>sys_bulletin_list 数据实体</returns>
		public CommonLib.Model.SYS_BULLETIN_LIST GetModel(int bULLETIN_ID )
		{
			CommonLib.Model.SYS_BULLETIN_LIST _obj=null;
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter("@bULLETIN_ID", SqlDbType.Int)
			};				
			_param[0].Value = bULLETIN_ID;
			
			string sqlStr="select * from SYS_BULLETIN_LIST where  BULLETIN_ID=@bULLETIN_ID";
			using(SqlDataReader dr=SqlHelper.ExecuteReader(Conn.SqlConnStr,CommandType.Text,sqlStr,_param))
			{
				while(dr.Read())
				{
            		_obj=PopulateSYS_BULLETIN_LISTModelFromDr(dr);
				}
			}
			return _obj;
		}
		#endregion
		
		#region ----根据DataRow,得到 数据实体
		/// <summary>
		/// 得到  sys_bulletin_list 数据实体
		/// </summary>
		/// <param name="row">row</param>
		/// <returns>sys_bulletin_list 数据实体</returns>
		public CommonLib.Model.SYS_BULLETIN_LIST PopulateSYS_BULLETIN_LISTModelFromDr(DataRow row)
		{
			CommonLib.Model.SYS_BULLETIN_LIST Obj = new CommonLib.Model.SYS_BULLETIN_LIST();
			if(row!=null)
			{
				Obj.BULLETIN_ID = (( row["BULLETIN_ID"])==DBNull.Value)?0:Convert.ToInt32( row["BULLETIN_ID"]);
				Obj.CREATE_TIME =  row["CREATE_TIME"].ToString();
				Obj.CREATOR_ID =  row["CREATOR_ID"].ToString();
				Obj.CREATOR =  row["CREATOR"].ToString();
				Obj.DEPT_ID =  row["DEPT_ID"].ToString();
				Obj.DEPT_NAME =  row["DEPT_NAME"].ToString();
				Obj.TITLE =  row["TITLE"].ToString();
				Obj.CONTENT =  row["CONTENT"].ToString();
				Obj.PUB_TIME =  row["PUB_TIME"].ToString();
				Obj.INVALIDE_TIME =  row["INVALIDE_TIME"].ToString();
				Obj.STATE = (( row["STATE"])==DBNull.Value)?0:Convert.ToInt32( row["STATE"]);
				Obj.ATTACH_FILES =  row["ATTACH_FILES"].ToString();
				Obj.WORK_ID =  row["WORK_ID"].ToString();
				Obj.REMARK =  row["REMARK"].ToString();
				Obj.ISRECOMMEND = ( ((bool) row["ISRECOMMEND"])?1:0);
			}
			else
			{
				return null;
			}
			return Obj;
		}
		#endregion
		
		#region ----根据IDataReader,得到 数据实体
        /// <summary>
		/// 得到  sys_bulletin_list 数据实体
		/// </summary>
		/// <param name="dr">dr</param>
		/// <returns>sys_bulletin_list 数据实体</returns>
		public CommonLib.Model.SYS_BULLETIN_LIST PopulateSYS_BULLETIN_LISTModelFromDr(IDataReader dr)
		{
			CommonLib.Model.SYS_BULLETIN_LIST Obj = new CommonLib.Model.SYS_BULLETIN_LIST();
			
				Obj.BULLETIN_ID = (( dr["BULLETIN_ID"])==DBNull.Value)?0:Convert.ToInt32( dr["BULLETIN_ID"]);
				Obj.CREATE_TIME =  dr["CREATE_TIME"].ToString();
				Obj.CREATOR_ID =  dr["CREATOR_ID"].ToString();
				Obj.CREATOR =  dr["CREATOR"].ToString();
				Obj.DEPT_ID =  dr["DEPT_ID"].ToString();
				Obj.DEPT_NAME =  dr["DEPT_NAME"].ToString();
				Obj.TITLE =  dr["TITLE"].ToString();
				Obj.CONTENT =  dr["CONTENT"].ToString();
				Obj.PUB_TIME =  dr["PUB_TIME"].ToString();
				Obj.INVALIDE_TIME =  dr["INVALIDE_TIME"].ToString();
				Obj.STATE = (( dr["STATE"])==DBNull.Value)?0:Convert.ToInt32( dr["STATE"]);
				Obj.ATTACH_FILES =  dr["ATTACH_FILES"].ToString();
				Obj.WORK_ID =  dr["WORK_ID"].ToString();
				Obj.REMARK =  dr["REMARK"].ToString();
				Obj.ISRECOMMEND = ( ((bool) dr["ISRECOMMEND"])?1:0);
			
			return Obj;
		}
		#endregion
///
		#region GetNewID 通过种子得到唯一ID,对单主键有效单，如果该表为多主键，则返回第一主键
		/// <summary>
        ///  通过种子得到唯一ID,对单主键有效单，如果该表为多主键，则返回第一主键
        /// </summary>
        /// <param name="bULLETIN_ID">bULLETIN_ID</param>
        /// <returns>int</returns>
		public int GetNewID()
		{
			return  DBCommon.GetNewIDForTable("SYS_BULLETIN_LIST","SYS_BULLETIN_LIST","");
		}
		#endregion
///
		#region	GetMaxID 得到最大ID	
		/// <summary>
		/// 得到最大ID
		/// </summary>
        /// <param name="bULLETIN_ID">bULLETIN_ID</param>
        /// <returns>int</returns>
		public int GetMaxID()
		{
			return  0;
		}
		#endregion
		
		#region	GetList 得到数据表指定字段列表的所有记录，可排序，
		/// <summary>
		/// 得到数据表SYS_BULLETIN_LIST所有记录，可排序




		/// </summary>
        /// <param name="sWhere">条件字符串</param>
        /// <param name="sOder">排序字段</param>
		/// <returns>DataSet</returns>
		public DataSet GetList(string sWhere, string sOder)
		{
			string	sqlStr="select * from "+TableString;
				
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
			if (sOder.Length > 0)
				sqlStr += " order by " + sOder;
			return SqlHelper.ExecuteDataset(Conn.SqlConnStr,CommandType.Text,sqlStr);
		}
		#endregion

		#region	GetListFS 得到数据表指定字段列表的所有记录，可排序，加工作流状态字段




		/// <summary>
		/// 得到数据表SYS_BULLETIN_LIST所有记录，可排序，加工作流状态字段




		/// </summary>
        /// <param name="FlowProcessId">流程ID</param>
        /// <param name="sWhere">条件字符串</param>
        /// <param name="sOder">排序字段</param>
		/// <returns>DataSet</returns>
		public DataSet GetListFS(string FlowProcessId, string sWhere, string sOder)
		{
			string	sqlStr="select SQL_A.*, isnull(SQL_B.work_state,'未发送') work_state from "+TableString+" left join view_wfInstance_state SQL_B on SQL_a.work_id=SQL_b.work_id";
				
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
			if (sOder.Length > 0)
				sqlStr += " order by " + sOder;
			return SqlHelper.ExecuteDataset(Conn.SqlConnStr,CommandType.Text,sqlStr);
		}
		#endregion


		#region GetPageList 根据条件和页号得到某页的记录集,+排序
		/// <summary>
		/// 根据条件和页号得到某页的记录集,+排序
		/// </summary>
        /// <param name="iPageSize">每页记录数</param>
		/// <param name="iPageIndex">页号</param>
		/// <param name="sWhere">条件字符串</param>
		/// <param name="sOder">排序字段</param>
        /// <returns>DataSet</returns>
		public DataSet GetPageList(int iPageSize,int iPageIndex, string sWhere, string sOder)
		{
			if (sOder.Length <=0)
				sOder = "BULLETIN_ID";
				
			string	sqlStr="select * from (select ROW_NUMBER() OVER(order by "+sOder+" ) as row, * from "+TableString;
			
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
			sqlStr += ") SQL1 where row between "+ Convert.ToString(iPageSize*(iPageIndex-1)+1) +" and "+Convert.ToString(iPageSize*iPageIndex);
			return SqlHelper.ExecuteDataset(Conn.SqlConnStr,CommandType.Text,sqlStr);
		}
		#endregion		

		#region GetPageListFS 根据条件和页号得到某页的记录集,+排序，加工作流状态字段




		/// <summary>
		/// 根据条件和页号得到某页的记录集,+排序，加工作流状态字段




		/// </summary>
        /// <param name="FlowProcessId">流程ID</param>
        /// <param name="iPageSize">每页记录数</param>
		/// <param name="iPageIndex">页号</param>
		/// <param name="sWhere">条件字符串</param>
		/// <param name="sOder">排序字段</param>
        /// <returns>DataSet</returns>
		public DataSet GetPageListFS(string FlowProcessId, int iPageSize,int iPageIndex, string sWhere, string sOder)
		{
			if (sOder.Length <=0)
				sOder = "BULLETIN_ID";
				
			string	sqlStr="select * from (select ROW_NUMBER() OVER(order by "+sOder+" ) as row, SQL_A.*,isnull(SQL_B.work_state,'未发送') work_state from "+TableString+" left join view_wfInstance_state SQL_B on sql_a.work_id=sql_b.work_id";
			
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
			sqlStr += ") SQL1 where row between "+ Convert.ToString(iPageSize*(iPageIndex-1)+1) +" and "+Convert.ToString(iPageSize*iPageIndex);
			return SqlHelper.ExecuteDataset(Conn.SqlConnStr,CommandType.Text,sqlStr);
		}
		#endregion		
		
		
		#region GetRecorderRowNum 判断某条记录所在的行号
		/// <summary>
		/// 判断某条记录所在的行号，调用者自己计算页号和行号
		/// </summary>
        /// <param name="sWhere">记录显示的条件</param>
        /// <param name="sOder">排序条件</param>
        /// <param name="iPageSize">每页记录数</param>
		/// <param name="主键列表">主键列表，需定位记录的键值</param>
        /// <returns>int 页码</returns>
		public int GetRecorderRowNum(string sWhere, string sOder, int iPageSize, int bULLETIN_ID)
		{
			if (sOder.Length <=0)
				sOder = "BULLETIN_ID";
				
			// 声明参数数组并赋值



			SqlParameter[] _param=
			{
				new SqlParameter("@bULLETIN_ID", SqlDbType.Int)
			};				
			_param[0].Value = bULLETIN_ID;
			
			string	sqlStr="select row from (select ROW_NUMBER() OVER(order by "+sOder+" ) as row, bULLETIN_ID from "+TableString;
			
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
				
			sqlStr = sqlStr + ") SQL1 where  BULLETIN_ID=@bULLETIN_ID";
			return Convert.ToInt32(SqlHelper.ExecuteScalar(Conn.SqlConnStr,CommandType.Text,sqlStr,_param));
		}
		#endregion
		
						
		#region GetRecorderCount 得到符合条件记录集的记录条数
		/// <summary>
		/// 得到符合条件记录集的记录条数
		/// </summary>
        /// <param name="FlowProcessId">流程ID</param>
		/// <param name="sWhere">条件字符串</param>
        /// <returns>int 记录数</returns>
		public int GetRecorderCount(string FlowProcessId, string sWhere)
		{
			string sqlStr ="";
			
			if (FlowProcessId.Length > 0)
            	sqlStr="select Count(*) from "+TableString+" left join view_wfInstance_state SQL_B on SQL_a.work_id=SQL_b.work_id";
			else
				sqlStr="select Count(*) from "+TableString;
				
			if (sWhere.Length>0)
				sqlStr += " where " + sWhere;
						
            return Convert.ToInt32(SqlHelper.ExecuteScalar(Conn.SqlConnStr,CommandType.Text,sqlStr));
		}
		#endregion				
		
		#region----------自定义实例化接口函数----------
		#endregion
    }
}
